package com.isdoub.testcamera.camera1;

import android.hardware.Camera;

/**
 * Created by had on 2018/7/15.
 */

public class CameraConfigs {

   public static Camera openCamera(int cameraid){
       try {
           Camera camera=Camera.open(cameraid);
           return camera;
       } catch (Exception e) {
           e.printStackTrace();
       }
       return null;

   }

   public static Camera.CameraInfo getFrontCameraInfo(){
       return getCameraInfo(Camera.CameraInfo.CAMERA_FACING_FRONT);
   }

   public static Camera.CameraInfo getBackCameraInfo(){
       return  getCameraInfo(Camera.CameraInfo.CAMERA_FACING_BACK);
   }



   public static Camera.CameraInfo getCameraInfo(int cameraFacing){
       int cameraNums=Camera.getNumberOfCameras();

       for (int i = 0; i < cameraNums; i++) {
           Camera.CameraInfo cameraInfo=new Camera.CameraInfo();
           Camera.getCameraInfo(i,cameraInfo);
         if (cameraFacing==cameraInfo.facing)return cameraInfo;
       }
       return null;
   }




}
